package com.songshuai.webapi.jobapi.common.enumerations;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public enum ClueStatus {
    NewClue(1017001, "销售新线索"),
    FollowIng(1017002, "销售待跟进"),
    Visited(1017003, "预约到访"),
    Deposit(1017004, "定金"),
    UnCompletePaid(1017005, "未完款"),
    CompletePaid(1017006, "已完款"),
    CustomFail(1017007, "失效客户"),
    UnVisited(1017008, "未到访客户"),
    ComSchoolArea(1017009, "合作校区域"),
    ComSchoolListen(1017010, "合作校试听");
    private int code;
    private String msg;

    ClueStatus(int code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public static int getCode(String define){
        try {
            return ClueStatus.valueOf(define).code;
        } catch (IllegalArgumentException e) {
            log.error("undefined error code: {}", define);
            return 0;
        }
    }

    public static String getMsg(String define){
        try {
            return ClueStatus.valueOf(define).msg;
        } catch (IllegalArgumentException e) {
            log.error("undefined error code: {}", define);
            return "";
        }
    }

    public static String getMsg(int code){
        for(ClueStatus err : ClueStatus.values()){
            if(err.code==code){
                return err.msg;
            }
        }
        return "errorCode not defined ";
    }

    public int getCode(){
        return code;
    }

    public String getMsg(){
        return msg;
    }
}
